<include file="Index/_meta" />
<body>
<div class="layui-fluid" style="margin-top: 20px">
    <article class="page-container">
        <form class="form form-horizontal" id="form-admin-add" method="post" action="">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="adminName" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="realname" name="realname">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" autocomplete="off"  placeholder="确认新密码" id="password2" name="password2">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="gender" type="radio" id="sex-1" checked value="1">
                        <label for="sex-1">男</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-2" name="gender" value="0">
                        <label for="sex-2">女</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="phone" name="phonenumber">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="@" name="email" id="email">
                </div>
            </div>
            <!--<div class="row cl">-->
                <!--<label class="form-label col-xs-4 col-sm-3">所在角色：</label>-->
                <!--<div class="formControls col-xs-8 col-sm-9">-->
                    <!--<?php foreach($roleData as $k => $v){?>-->
                    <!--<label><input type="radio" name="role_id[]" value="<?php echo $v['id']; ?>"><?php echo $v['role_name']?>-->
                        <!--&nbsp;&nbsp;</label>-->
                    <!--<?php }?>-->
                <!--</div>-->
            <!--</div>-->

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属角色：</label>
                <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
                    <select class="select" name="role_id[]" size="1">
                        <!--<option value="0">顶级权限</option>-->
                        <?php foreach($roleData as $v){?>
                        <?php if($v['id']==2){continue;}?>
                        <option value="<?php echo $v['id']?>">
                        <?php echo str_repeat('-',8*$v['level']),$v
['role_name']?>
                    </option>
                        <?php }?>
                    </select>
		        </span>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <label>
                            <input name="is_use" type="radio" checked value="1">
                            启用</label>
                    </div>
                    <div class="radio-box">
                        <label><input type="radio" id="" name="is_use" value="0">
                            禁用</label>
                    </div>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input id="tijiao" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
</div>
</body>

<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        // 操作对象
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;

        $("#tijiao").click(function () {
            $.post("/index.php/home/admin/admin_add", $('form').serialize(),
                function(result){
                    if(result.status == '0'){
                        layer.alert(result.message);
                    }
                    if(result.status == '1'){
                        layer.open({
                            content:result.message,
                            icon:1,
                            yes:function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.$('.refresh').click();  //添加成功获取一下数据
                                parent.layer.close(index); //再执行关闭
                            }
                        });
                    }
                },
                "JSON");
        })
    })
</script>